﻿using System;

namespace NeuralLib.ActivationFunction
{
    [Serializable]
    public class SigmoidFunction : IActivationFunction
    {
        private double _alpha = 2;

        public double Alpha
        {
            get { return _alpha; }
            set { _alpha = value; }
        }

        public SigmoidFunction() { }

        public SigmoidFunction(double alpha)
        {
            _alpha = alpha;
        }

        public double Function(double x)
        {
            return (1 / (1 + Math.Exp(-_alpha * x)));
        }

        public double Derivative(double x)
        {
            var y = Function(x);

            return (_alpha * y * (1 - y));
        }

        public double Derivative2(double y)
        {
            return (_alpha * y * (1 - y));
        }
    }

}
